$(document).ready(function () {
    dzzl.onload();
})
var dzzl = (function () {
    return {
        onload : function () {
            dzzl.tableData();
            dzzl.delAllBtn();
            dzzl.alertBox();
        },
       /*表格数据交互*/
      tableData: function() {
 		var data = [{
 				"number": "01",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"已审核",
 				"operation": null
 			},
 			{
 				"number": "02",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"已审核",
 				"operation": null
 			},
 			{
 				"number": "03",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"未审核",
 				"operation": null
 			},
 			{
 				"number": "04",
 				"filename": "税务登记正本",
 				"uploaddate": "2018-08-23",
 				"state":"已审核",
 				"operation": null
 			}
 		];
 		var table = $('#wepDzzl').DataTable({
 			"data": data,
 			"columnDefs": [{
 					"targets": -1,
 					"data": null,
 					"render": function(data, type, full, meta) {
 						return '<a href="#"><span class="btn wxl_bg_lan1">查看</span></a><a href="#"><span class="del_row btn wxl_bg_red">删除</span></a>'
 					}
 				},
 				{
 					'targets': 0,
 					'className': 'dt-body-center',
 					'render': function(data, type, row) {
 						return '<input class="checkchild" type="checkbox"/>';
 					}
 				}
 			],
 			"columns": [
 			    {
 					"data": "btn"
 				},
 			    {
 					"data": "number"
 				},
 				{
 					"data": "filename"
 				},
 				{
 					"data": "uploaddate"
 				},
 				{
 					"data": "state"
 				},
 				{
 					"data": "operation"
 				}
 			],
// 			"paging": false,
 			"info": false,
 			"ordering": false,
 			"lengthChange": false,
 			"searching": false,
 			"fnInitComplete": function (oSettings, json) {/*判断认证状态显示字体颜色*/
	            for(var i=0;i<$('#wepDzzl tbody tr').length;i++){
	            	if($('#wepDzzl tbody tr').eq(i).find('td').eq(4).text() == "已审核"){
	            		$('#wepDzzl tbody tr').eq(i).find('td').eq(4).addClass('ycl')
	            	}else{
	            		$('#wepDzzl tbody tr').eq(i).find('td').eq(4).addClass('wcl')
	            	}
	            }
$('.wxl_bg_lan1').parent().on('click',function(){
               parent.yhzx_zrr.alertBox1('.bodyNode');
              });
	        }
 		});
 		/*删除行*/
 		$('#wepDzzl tbody').on( 'click', '.del_row', function () {
 			var row = $(this).parents('tr');
 			table.row(row).remove().draw( false );
	    } );
   	  },
   	  /*点击删除*/
   	  delAllBtn:function(){
   		$('.wep_rz_del').on('click',function(){
   			parent.yhzx_zrr.delAll("确定要删除吗？");
   		})
   	  },
        /*点击增加弹出框*/
     alertBox:function(){
     	$('.wep_rz_add').on('click',function(){
     		var html1 = $('.wep_alert_icon').html();
     		$(window.parent.document).find('.wep_dzzl_addBox').html(html1);
//   		$('.wep_dzzl_addBox').html(html1);
     		parent.yhzx_zrr.alertBox('.wep_dzzl_addBox','900px','auto');
     		parent.yhzx_zrr.imgUploadF();
     	})
     }
    }
})();